package com.app.couponsharelife.ui.main.me.order

import androidx.fragment.app.Fragment
import com.app.couponsharelife.R
import com.app.couponsharelife.base.BaseActivity
import com.app.couponsharelife.ui.adapter.ViewPagerAdapter
import kotlinx.android.synthetic.main.activity_order.*
import kotlinx.android.synthetic.main.common_tool_bar_layout.*

class OrderActivity : BaseActivity() {

    override val viewLayoutId: Int get() = R.layout.activity_order

    private var mAdapter: ViewPagerAdapter? = null

    private var mTitles = arrayListOf<String>()

    private var mPagers = arrayListOf<Fragment>()

    override fun initViews() {
        initToolBar()
        initViewPager()
    }


    private fun initToolBar() {
        ivBack.setOnClickListener { finish() }
        tvToolBarTitle.text = "我的订单"
//        tvRightBtn.visibility = View.VISIBLE
//        tvRightBtn.setOnClickListener { }
    }

    private fun initViewPager() {
        with(mTitles) {
            add("全部")
            add("已付款")
            add("已结算")
            add("已失效")
        }
        with(mPagers) {
            add(OrderFragment.newInstance(3))
            add(OrderFragment.newInstance(1))
            add(OrderFragment.newInstance(2))
            add(OrderFragment.newInstance(0))
        }
        mAdapter = ViewPagerAdapter(supportFragmentManager, mPagers, mTitles)
        mViewPager.adapter = mAdapter
        mViewPager.offscreenPageLimit = 4
        mTabLayout.setupWithViewPager(mViewPager)
    }

    private fun loadData() {

    }
}
